package com.example.demo0

import java.util.*

class StockUpdate:Observable(){
    private val observers = mutableSetOf<Observer>()
    fun setStockChanged(price:Int){
        this.observers.forEach{
            it.update(this,price)
        }
    }

}

class StockDisplay:Observer{
    override fun update(p0: Observable?, p1: Any?) {
       if(p0 is StockUpdate){
           println("The latest stock price is ${p1}.")
       }
    }

}


























